<?php

declare(strict_types=1);
/**
 * This file is part of Hyperf.
 *
 * @link     https://www.hyperf.io
 * @document https://hyperf.wiki
 * @contact  group@hyperf.io
 * @license  https://github.com/hyperf/hyperf/blob/master/LICENSE
 * @author   howe <howe1995@163.com>
 */
use Hyperf\Database\Migrations\Migration;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Schema\Schema;

return new class() extends Migration {
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('groups', function (Blueprint $table) {
            $table->id();
            $table->string('name', 50)->default('');
            $table->unsignedBigInteger('owner')->default(0)->comment('群主');
            $table->unsignedBigInteger('send_user')->default(0)->comment('发送最新消息的用户ID');
            $table->string('at_users', 255)->nullable()->comment('被@的用户ID');
            $table->text('content')->nullable()->comment('最新消息');
            $table->unsignedBigInteger('time')->default(0)->comment('发送最新消息时间');
            $table->integer('notice_user')->unsigned()->default(0);
            $table->text('notice')->nullable();
            $table->integer('noticed_at')->unsigned()->default(0);
            $table->json('setting');
            $table->timestamp('deleted_at')->nullable()->default(null);
            $table->timestamp('created_at')->useCurrent();
            $table->timestamp('updated_at')->useCurrent();
            $table->comment('群信息表');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('groups');
    }
};
